package com.vrv.app.cyberspace.modules.sys.controller;


import com.baomidou.mybatisplus.plugins.Page;
import com.vrv.app.cyberspace.common.utils.JSONResult;
import com.vrv.app.cyberspace.common.validator.Assert;
import com.vrv.app.cyberspace.common.validator.ValidatorUtils;
import com.vrv.app.cyberspace.modules.sys.entity.RiskManageTable;
import com.vrv.app.cyberspace.modules.sys.service.IRiskManageTableService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author sm
 * @since 2018-01-18
 */
@Api(description = "风险管理")
@RestController
@RequestMapping("/sys/riskManage")
public class RiskManageTableController {
    @Autowired
    private IRiskManageTableService riskManageTableService;

    @ApiOperation(value = "风险通知", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "返回成功信息")
    })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "title", value = "标题", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "happenTime", value = "发生日期", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "approvalUserID", value = "请示人ID", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "advice", value = "研判意见", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "primaryRiskType", value = "初判风险类型", required = true, dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "primaryRiskGrade", value = "初判风险等级", required = true, dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "basicSituationDescription", value = "基本情况描述", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "verificationMethod", value = "验证方法", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "trendHazards", value = "发展趋势及可能危害", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "suggestion", value = "建议应对措施", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "infrastructure_information", value = "信息基础设施", dataType = "String", paramType = "query", example = "JSON.stringify([{name: \"测试\",unit: \"\",leadingOfficial: \"\",contactPhone: \"\",ip: \"\",domainName: \"\",url: \"\"}])"),
            @ApiImplicitParam(name = "fax", value = "传真,事件风险都需要", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "measureToken", value = "已采取的措施和效果,事件风险都需要", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "remarks", value = "备注,事件风险都需要", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "enclosure", value = "附件,事件风险都需要", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "influenceHarm", value = "影响及危害描述,事件风险都需要", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "regionIDs", value = "地域表IDs组合,事件风险都需要", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "industryIDs", value = "行业IDs组合,事件风险都需要", dataType = "String", paramType = "query"),
    })
    @PostMapping()
    public JSONResult addToRiskManage(Integer id, @ApiIgnore RiskManageTable rmt, String infrastructure_information, String advice) {
        Assert.isNull(id, "id不能为空");
        ValidatorUtils.validateEntity(rmt);
        return riskManageTableService.addToRiskManage(id, rmt, infrastructure_information, advice);
    }

    @GetMapping("/{baseID}")
    public JSONResult getRiskManage(@PathVariable Integer baseID) {
        return riskManageTableService.getRiskManage(baseID);
    }

    @ApiOperation(value = "风险管理列表", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "返回风险管理列表")
    })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页码", required = true, dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "size", value = "条数", required = true, dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "warningLevel", value = "可多选1,2 预警等级:0无 1红 2橙 3黄 4蓝", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "riskLevel", value = "可多选1,2 风险等级:1很高 2高 3中等 4低 5很低", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "timeType", value = "时间类型：1为创建时间 2为更新时间", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "预警事件管理状态 1--在办 2--办结", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "title", value = "标题", dataType = "String", paramType = "query"),
    })
    @GetMapping()
    public JSONResult getListRiskManage(Integer page, Integer size, String startTime, String endTime, String warningLevel, String riskLevel, Integer timeType, Integer status, String title) {
        return riskManageTableService.getListRiskManage(new Page<>(page, size), startTime, endTime, warningLevel, riskLevel, timeType, status, title);
    }

    @RequestMapping("/release")
    public JSONResult releaseRisk(RiskManageTable rmt) {
        return riskManageTableService.releaseRisk(rmt);
    }

    @ApiOperation(value = "专家/我的任务", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "返回专家任务列表")
    })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页码", required = true, dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "size", value = "条数", required = true, dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "type", value = "类型：2风险 3事件", required = true, dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "状态：0待办 1已办 2办结", required = true, dataType = "Integer", paramType = "query"),
    })
    @GetMapping("/getListProfessorRisk")
    public JSONResult getListProfessorRisk(Integer page, Integer size, Integer status) {
        Assert.isNull(page, "page不能为空");
        Assert.isNull(size, "size不能为空");
        Assert.isNull(size, "type不能为空");
        return riskManageTableService.getListProfessorRisk(new Page<>(page, size), status);
    }
}

